<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>国省自检--${fns:getConfig('productName')}</title>
<link rel="stylesheet" href="${ctx}/styles/gsjcss/common.css">
<script type="text/javascript">
function btnClick(){
	var url = '${ctx}/levelAdministration/search.do?projectId=${fns:encodeParamUrl(projectId)}&menuId=${fns:encodeParamUrl(menuId)}';
	var data = {};
	if($('#btnSearch').length>0){ //有搜索按钮的情况下 获取条件进行搜索
		//将条件提取出来 
		//将条件存入data中
		//ajax请求   得到数据
		data['retrieval'] = getJson('condition');
		loadData(url,data);
	} else {
		loadData(url,data);
	}
}
//ajax执行成功之后的回调方法
function loadDataToTable(data){
	var attment = data['att'];
	var glmbResult = data['glmbResult'];
	var jgglResult = data['jgglResult'];
	var ndkhResult = data['ndkhResult'];
	var glmbNum = data['glmbNum'];
	var jgglNum = data['jgglNum'];
	var ndkhNum = data['ndkhNum'];
	loadAttachment(attment);
	
	//返回评分结果
	if(data['years'] != undefined){
		var years = data['years'];
		//每次搜索前清空表格
		$('#checkResult').empty();
		var result="";
		var content = '<table style="width:98%;text-align:center;margin-top:5px;" border="1"><thead><tr>'+
					  '<th rowspan="2">年份</th><th colspan="3">相关文件检查情况(有的打√，没有的打×)</th><th rowspan="2">存在不足的项数</th>'+
					  '<th rowspan="2">检查得分</th><th rowspan="2">完善度</th></tr>'+
					  '<tr><th>管理目标</th><th>计划执行</th><th>监督考评</th></tr></thead><tbody></tbody></table>';			  
		$('#checkResult').append(content);
		
		var a,b,c = 0;
		for (var i = 0; i < glmbResult.length; i++) {
			result += '<tr><td>'+years[i]+'</td>';
			if (glmbResult[i] == 1) {
				result += '<td>√</td>';
			} else {
				result += '<td>×</td>';
				a++;
			}
			
			for (var j = i; j < jgglResult.length; j++) {
				if (jgglResult[j] == 1) {
					result += '<td>√</td>';
				} else {
					result += '<td>×</td>';
					b++;
				}
				break;
			}
			
			
			for (var j = i; j < ndkhResult.length; j++) {
				if (ndkhResult[j] == 1) {
					result += '<td>√</td>';
				} else {
					result += '<td>×</td>';
					c++;
				}
				break;
			}
			
			if (i == 0) {
				if (glmbNum + jgglNum + ndkhNum >= years.length*3) {
					result += '<td rowspan='+glmbResult.length+'>0项</td>';
				} else if ((glmbNum + jgglNum) >=years.length*2 || (jgglNum + ndkhNum) >= years.length*2 || (glmbNum + ndkhNum) >= years.length*2) {
					result += '<td rowspan='+glmbResult.length+'>1项</td>';
				} else if (glmbNum < years.length && jgglNum < years.length + ndkhNum < years.length) {
					result += '<td rowspan='+glmbResult.length+'>3项</td>';
				} else {
					result += '<td rowspan='+glmbResult.length+'>2项</td>';
				}
				
				result += '<td class="sumTd" rowspan='+glmbResult.length+'>'+data['sum']+'</td>'+
				          '<td class="perTd" rowspan='+glmbResult.length+'>'+data['percent']+'%</td>';
			}
			result += '</tr>';
		}
		$('#checkResult tbody').append(result);
	}
	
}
</script>
</head>
<body>
	<div id="x_top"></div>
	<tags:message content="${msg}" />
	<c:if test="${not empty checkTable.id}">
		<div style="text-align:center">
			<a href="javascript:void(0);" class="btn btn-primary" onclick="downWord('${ctx}/levelAdministration/downWord.do?projectId=${fns:encodeParamUrl(projectId)}&menuId=${fns:encodeParamUrl(menuId)}');" id= "btnDown" role="button" ><div id="x_v"></div></a>
		</div>
	</c:if>
	<form id="checkForm" class="form-horizontal"  method="POST"  name="checkForm" action="${ctx}/levelAdministration/save.do?left=${fns:encodeParam(left)}&parentId=${fns:encodeParam(parentId)}&projectId=${fns:encodeParam(projectId)}&menuId=${fns:encodeParam(menuId)}&leftChild=${fns:encodeParam(leftChild)}">
		<input type="hidden" name="token" value="${token}">
		<div id="show">
			<div id="showTable" class="showTable">
				<jsp:include page="/WEB-INF/views/check/common.jsp"/> 
				<div class="model">
					<div>
						<legend>三、检查条件及设置</legend>
						<div class="content-title" id="condition">
							<div style="margin-right:10px;margin-top:5px;">
								<span>省、市(或市、区县)两级公路管理机构主体明确，职责清晰，年度管理目标明确，计划执行情况好，认真开展年度考核与总结得分<font style="color:red;">*</font>：</span>
								<input type='text' name = "yearFull" id="yearFull" value="3" class="required conInput"/>
							</div>
							<div style="float:left;margin-right:10px;margin-top:5px;">
								<span>管理目标、计划执行或行业监管存在1项不足的得分<font style="color:red;">*</font>：</span>
								<input type='text' name = "yearPart" id="yearPart" value="2" class="required conInput"/>
								<span>管理目标、计划执行或行业监管存在2项不足的得分<font style="color:red;">*</font>：</span>
								<input type='text' name = "poitMark" id="poitMark" value="1" class="required conInput"/>
							</div>
							<div id="x_s" style="float:right">
								<div class="x_ico"></div>
								<a href="#javascript:void(0)" onclick= "btnClick();"  id= "btnSearch" role="button" >搜索&nbsp;</a>
							</div>
						</div>
					</div>
				</div>
				<div class="model">
					<div>
						<legend>四、检索结果</legend>
						<div class="content-title">
							<div class="tabbox">
								<div class="tab">
									<c:forEach items="${childMenuList}" var="menu"  varStatus="idxStatus">
											<a href="javascript:;" ${idxStatus.index==0?"class='on'":""}>${menu.name}</a>
									</c:forEach>
							    </div>
							    <div class="content">
							    	<ul>
							    		<c:forEach items="${childMenuList}" var="menu"  varStatus="idxStatus">
							    			<li>
							    				<table style="width:99.8%;text-align:center;margin-top:5px;" border="1" id="${menu.tag}">
									    			<thead>
									    				<th>序号</th>
										    			<th>操作</th>
										    			<th>发文单位</th>
										    			<th>上传用户</th>
										    			<th>文件名</th>
										    			<th>发文日期</th>
										    			<th>上传日期</th>
										    			<th>文件大小</th>
										    			<th>文件类型</th>
										    		</thead>
								    				<tbody>
									    						
									    			</tbody>
							    				</table>
							    			</li>
							    		</c:forEach>
							        </ul>
							    </div>
							</div>
						</div>
					</div>
				</div>
				<div class="model">
					<div>
						<legend>五、检查评分</legend>
						<div class="content-title" id="checkResult">
						
						</div>
					</div>
				</div>
				<div class="model">
					<div class="content-btn">
						<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存" />
						&nbsp;&nbsp;&nbsp;&nbsp;
						<input id="btnCancel" class="btn" type="button" value="返 回" onclick="toBack()" />
					</div>
				</div>
			</div>
		</div>
	</form>
	<script src="${ctxStatic}/js/check/checkCommon.js" type="text/javascript"></script>
</body>
</html>